<?php
/**
 * Created by PhpStorm.
 * User: zouhua
 * Date: 2017/5/5
 * Time: 16:12
 */

namespace app\actions;


use app\models\Activity;
use app\models\ActivityApply;

class UserPreInterview extends UserList {

    public $applyList;

    public function beforeRun() {
        if (!parent::beforeRun()) {
            return FALSE;
        }

        $where = ['uid' => $this->user->id, 'type' => Activity::TYPE_JOB];
        $this->applyList = ActivityApply::find()->where($where)
            ->asArray()->indexBy('aid')->all();

        $aidList = $this->applyList ? array_keys($this->applyList) : 0;
        $this->where = ['id' => $aidList];

        $this->modelClass = Activity::className();
        $this->_view = 'activity';
        return TRUE;
    }

    public function render($params = [], $view = NULL) {
        $this->controller->view->title = $this->title;
        if (!isset($params['user'])) {
            $params['user'] = $this->user;
        }
        $params['applyList'] = $this->applyList;
        $view = str_replace('_ajax', '', $view);
        return $this->controller->render($params, $view);
    }
}